<?php
namespace Inationsoft\Koma;

use Inationsoft\NS;
use Inationsoft\NS\Core\Controller;
use Inationsoft\NS\Core\Config;
use Inationsoft\NS\Exception\HttpRequestException;
use Inationsoft\NS\Exception\PageNotFoundException;

define('_NAMESPACE_', '\Inationsoft\Koma');

class Asset extends Controller {
	function _main() {
		Config::getInstance()->Koma->ThemeMainTemplate = null;
	}

	function css($css) {		
		if(is_file($file = NS_SYSTEM_PATH . '/asset/cache/' . $css . '.css')) {
			if(is_readable($file)) {
				header('Cache-Control: max-age=2592000, public'); 
				header('Expires-Active: On'); 
				header('Expires: Fri, 1 Jan 2500 01:01:01 GMT'); 
				header('Pragma:');
				header('Content-type: text/css');

				readfile($file);
			} else throw new HttpRequestException(403);
		} else  throw new PageNotFoundException();
	}

	function js($js) {
		if(is_file($file = NS_SYSTEM_PATH . '/asset/cache/' . $js . '.js')) {
			if(is_readable($file)) {
				header('Cache-Control: max-age=2592000, public'); 
				header('Expires-Active: On'); 
				header('Expires: Fri, 1 Jan 2500 01:01:01 GMT'); 
				header('Pragma:');
				header('Content-type: text/javascript');

				readfile($file);
			} else throw new HttpRequestException(403);
		} else  throw new PageNotFoundException();
	}
}
?>